package com.hp.bon.sgw.wkflow.impl;

import java.util.Map;

import com.hp.bon.sgw.domain.ConvMapInfo;
import com.hp.bon.sgw.util.dcc.DccAvpHelper;
import com.hp.bon.sgw.wkflow.FlowVarObj;
import com.hp.ocs.diameter.message.Message;

/**
 * 负责解析DCC消息的AVP值
 * 
 * @author wuzhih
 * 
 */
public class DCCMsgVarObj extends FlowVarObj {
	private final Message dccMsg;
	private final Map<String, ConvMapInfo> allAVPNamesMap;
	private final Map<Integer, ConvMapInfo> allAvpCodeMap;
	public Message getMessage()
	{
		return dccMsg;
	}
	
	public Map<Integer, ConvMapInfo> getAllAvpCodeMap() {
		return allAvpCodeMap;
	}

	public Map<String, ConvMapInfo> getAllAVPNamesMap() {
		return allAVPNamesMap;
	}

	public DCCMsgVarObj(Message dccMsg, Map<String, ConvMapInfo> allAVPNamesMap,Map<Integer, ConvMapInfo> allAvpCodeMap) {
		super();
		this.dccMsg = dccMsg;
		this.allAVPNamesMap = allAVPNamesMap;
		this.allAvpCodeMap=allAvpCodeMap;
	}

	@Override
	public Object getProperty(String express) {
		if (dccMsg == null) {
			return null;
		}
		String avpName = express;
		// System.out.println("get dcc msg property " + avpName + " dcc msg "
		// + dccMsg.getDictionary().toString());
		return DccAvpHelper.getAVPValue(dccMsg, avpName, allAVPNamesMap);
	}

}
